From 786e9d351cce774e5d5baa4fac92603b25c6e50a Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 26 Jan 2021 12:54:53 +0000 Subject: [PATCH] Make the inout argument logic clearer It's easy to misread a `+=`. --- gdk/gdksurface.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c index 52b45edfd1..aaeb6d21b4 100644 --- a/gdk/gdksurface.c +++ b/gdk/gdksurface.c @@ -2980,9 +2980,13 @@ gdk_surface_translate_coordinates (GdkSurface *from, double *x, double *y) { + double in_x, in_y, out_x, out_y; int x1, y1, x2, y2; GdkSurface *f, *t; + in_x = *x; + in_y = *y; + x1 = 0; y1 = 0; f = from; @@ -3006,8 +3010,11 @@ gdk_surface_translate_coordinates (GdkSurface *from, if (f != t) return FALSE; - *x += x1 - x2; - *y += y1 - y2; + out_x = in_x + (x1 - x2); + out_y = in_y + (y1 - y2); + + *x = out_x; + *y = out_y; return TRUE; } -- 2.30.2